home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 606 < prev    next >
Encoding:
Text File  |  1996-08-05  |  967 b   |  40 lines

  1. Newsgroups: comp.lang.c++
  2. Path: artemis.sto.fdata.se!news
  3. From: Niklas Mellin <niklas.mellin@sto.fdata.se>
  4. Subject: Re: How to change the following BASIC into C++?
  5. Sender: news@artemis.sto.fdata.se (UseNet NetNews)
  6. Message-ID: <30ECFE8F.541B@sto.fdata.se>
  7. Date: Fri, 5 Jan 1996 10:33:51 GMT
  8. Content-Transfer-Encoding: 7bit
  9. Content-Type: text/plain; charset=us-ascii
  10. References: <4ciit7$6fa@news.ust.hk>
  11. Mime-Version: 1.0
  12. X-Mailer: Mozilla 2.0b4 (WinNT; I)
  13. Organization: WM-data F÷rsvarsdata AB, Sweden
  14.  
  15. Wong Siu Ki wrote:
  16. > Hi!
  17. > I want to know how to write the following things in C++:
  18. > 10 a$=inkey$
  19. > 20 print "ok"
  20. > 30 if a$="" then goto 10
  21.  
  22. Here is one way of doing it. kbhit() returns non-zero if the
  23. user has pressed any key. 
  24.  
  25. #include <conio.h>    // declaration of kbhit()
  26. #include <iostream.h> // declaration of cout
  27.  
  28. int main(int, char* [])
  29. {
  30.   while (!kbhit())
  31.   {
  32.     // Here is a good place to put a delay
  33.     cout << "Ok ";
  34.   }
  35.   return 0;
  36. }
  37.